#!coding=utf-8
import threading
import time
from print_s import print_safe as print
# 创建栅栏对象
barrier = threading.Barrier(3)

# 线程函数
def worker():
    print(f"Worker {threading.current_thread().name} is waiting at the barrier.")
    barrier.wait()
    print(f"Worker {threading.current_thread().name} is proceeding after the barrier.")

# 创建并启动线程
threads = []
for i in range(3):
    thread = threading.Thread(target=worker)
    threads.append(thread)
    thread.start()

# 等待线程完成
for thread in threads:
    thread.join()

print("All workers have passed the barrier.")
